{extend name="Base/base"/}

{block name="body"}
<div class="main-title">
    <h2>添加商品服务详细信息           </h2>
</div>
<div class="with-padding">


    <div class="tab-wrap" style="margin-bottom: 5px">
        <ul class="nav nav-secondary group_nav"></ul>
    </div>
    {notempty name="list"}
    <form action="{:url('',array('action'=>'add'))}" name="images" method="post" class="form-horizontal">
        <label class="item-label">栏目名字    </label>
        <div class="controls ">
            <input type="hidden" name="id" value="{$list.id}">
            <input type="text" name="title" value="{$list.title}" class="text input-large form-control"
                   style="width: 400px"
                   placeholder="首页标题">
            <p class="lead"></p>
        </div>
        <label class="item-label">图片LOGO    </label>
        <div class="controls ">
            <div class="controls">
                <div id="upload_single_image_image" style="padding-bottom: 5px;" class="webuploader-container">
                    <div class="webuploader-pick">选择图片</div>
                    <div id="rt_rt_1b4t64277n7iv2s1e3vg7d1rtu1" style="position: absolute; top: 0px; left: 0px; width: 64px; height: 28px; overflow: hidden; bottom: auto; right: auto;">
                        <input type="file" class="webuploader-element-invisible" multiple="multiple"
                               accept="image/*">
                        <label style="opacity: 0; width: 100%; height: 100%; display: block; cursor: pointer; background: rgb(255, 255, 255);"></label>
                    </div>
                </div>
                <input class="attach" type="hidden" name="image" value="{$list.image_id}">
                <div class="upload-img-box">
                    <div class="upload-pre-item popup-gallery">
                        <div class="each">
                            <a><img src="{$list.image}"></a>
                            <div class="text-center opacity del_btn"></div>
                            <div onclick="admin_image.removeImage($(this),{$list.id})" class="text-center del_btn">删除
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--上传文件-->
            <script>
                $(function () {
                    var uploader_image= WebUploader.create({
                        // 选完文件后，是否自动上传。
                        auto: true,
                        // swf文件路径
                        swf: "__ROOT__js/ext/webuploader/js/Uploader.swf",
                        // 文件接收服务端。
                        server: "{:url('shop/upload')}",
                        // 选择文件的按钮。可选。
                        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                        pick: '#upload_single_image_image',
                        // 只允许选择图片文件
                        accept: {
                            title: 'Images',
                            extensions: 'gif,jpg,jpeg,bmp,png',
                            mimeTypes: 'image/*'
                        }
                    });
                    uploader_image.on('fileQueued', function (file) {
                        uploader_image.upload();
                    });
                    /*上传成功**/
                    uploader_image.on('uploadSuccess', function (file, data) {
                        //console.log(data);
                        if (data.status) {
                            $("[name='image']").val(data.id);
                            $("[name='image']").parent().find('.upload-pre-item').html(
                                '<div class="each"><a href="'+ data.url+'" disabled="true" title="点击查看大图"><img src="'+
                                data.url+'"></a><div class="text-center opacity del_btn" ></div>' +
                                '<div onclick="admin_image.removeImage($(this),'+data.id+')"  class="text-center del_btn">删除</div></div>');
                            uploader_image.reset();
                        } else {
                            updateAlert(data.info);
                            setTimeout(function () {
                                $('#top-alert').find('button').click();
                                $(that).removeClass('disabled').prop('disabled', false);
                            }, 1500);
                        }
                    });
                })
            </script>
        </div>
        <label class="item-label">内容简介    </label>
        <div class="controls ">
                    <textarea type="text" name="content" value="" class="text input-large form-control"
                              style="width: 400px">{$list.content}</textarea>
        </div>
        <label class="item-label">所属栏目    </label>
        <div class="controls ">
            <select name="cat_title" class="form-control" style="width:auto;">
                <option value="{$list.cat_title}" selected="">{$list.cat_title}</option>
                {foreach name="tag" item="c"}
                <option value="{$c.title}">{$c.title}&nbsp;</option>
                {/foreach}
            </select>
        </div>
        <label class="item-label">标题1(第一栏)    </label>
        <div class="controls ">
            <input type="text" name="title1" value="{$list.title1}" class="text input-large form-control"
                   style="width: 400px"></div>
        <label class="item-label">标题1介绍    </label>
        <div class="controls ">
            <script id="brief1" name="detile1" class="edui-default"
                    style="width: 500px;">{notempty name="list.detile1"}{$list.detile1}{/notempty}</script>
        </div>
        <label class="item-label">标题2(第二栏)    </label>
        <div class="controls ">
            <input type="text" name="title2" value="{$list.title2}" class="text input-large form-control"
                   style="width: 400px">
        </div>
        <label class="item-label">标题2介绍    </label>
        <div class="controls ">
            <script id="brief2" name="detile2" class="edui-default"
                    style="width: 500px;">{notempty name="list.detile2"}{$list.detile2}{/notempty}</script>
        </div>

        <label class="item-label">标题3(第三栏)    </label>
        <div class="controls ">
            <input type="text" name="title3" value="{$list.title3}" class="text input-large form-control"
                   style="width: 400px">
        </div>
        <label class="item-label">图文说明说明   </label>
        <div class="controls ">

            <script id="brief3" name="detile3" class="edui-default"
                    style="width: 500px;">{notempty name="list.detile3"}{$list.detile3}{/notempty}</script>

        </div>
        <label class="item-label">商品单价    </label>
        <div class="controls ">
            <input type="text" name="price" value="{$list.price}" class="text input-large form-control"
                   style="width: 400px">
        </div>
        <label class="item-label">价格说明(第四栏)   </label>
        <div class="controls ">
            <input type="text" name="title4" value="{$list.title4}" class="text input-large form-control"
                   style="width: 400px">
        </div>

        <label class="item-label">优惠介绍    </label>
        <div class="controls ">
            <script id="brief4" name="detile4" class="edui-default"
                    style="width: 500px;">{notempty name="list.detile4"}{$list.detile4}{/notempty}</script>
        </div>
        {notempty name="price"}
        <label class="item-label">价格选项   </label>
        <div class="controls ">
            {foreach name="list['price_int']" item="price"}
            <?php $price = explode('￥',$price);?>
            <label style="display: block"><input type="text" name="price1[]" value="{$price[0]}"
                                                 style="width: 200px;margin-left: 10px;"
                                                 placeholder="价格说明" ><input type="text" name="price2[]"
                                                                            value="{$price[1]}"
                                                                            style="width: 80px;margin-left: 10px;" placeholder="价格"></label>
            {/foreach}
            <label style="display: block"><input type="text" name="price1[]" value="" style="width: 200px;margin-left: 10px;"
                                                 placeholder="价格说明" ><input type="text" name="price2[]" value=""
                                                                            style="width: 80px;margin-left: 10px;" placeholder="价格"></label>
            <label style="display: block"><input type="text" name="price1[]" value="" style="width: 200px;margin-left: 10px;"
                                                 placeholder="价格说明" ><input type="text" name="price2[]" value=""
                                                                            style="width: 80px;margin-left: 10px;" placeholder="价格"></label>
            <label style="display: block"><input type="text" name="price1[]" value="" style="width: 200px;margin-left: 10px;"
                                                             placeholder="价格说明" ><input type="text" name="price2[]" value=""
                                                                                        style="width: 80px;margin-left: 10px;" placeholder="价格"></label>

        </div>
        {/notempty}
        <label class="item-label">排序    </label>
        <div class="controls ">
            <input type="text" name="sort" value="{$list.sort}" class="text input-large form-control"
                   style="width: 400px"></div>
        <label class="item-label">状态    </label>
        <div class="controls ">
            <label for="id_stauts_0"><input id="id_stauts_0" name="status" value="0" type="radio" {if condition="$list.status==0"}checked=""{/if}>正常</label>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <label for="id_stauts_1"> <input id="id_stauts_1" name="status" value="1" type="radio" {if
                                             condition="$list.status==1"}checked=""{/if}>隐藏</label>
        </div>
        <label class="item-label">创建时间    </label>
        <div class="controls ">
            <input type="hidden" name="create_time" value="{$list.create_time}">
            <input type="text" id="datetimepicker" data-field-name="create_time"
                   class="text input-large form-datetime time form-control" style="width: 400px"
                   value="{$list.create_time}"
                   placeholder="请选择时间">
        </div>
        <div class="form-item">
            <button class="btn submit-btn ajax-post btn-success" id="submit" type="submit" target-form="form-horizontal">确定</button>  &nbsp;<button onclick="javascript:history.back(-1);return false;" class="btn btn-return">返回</button>  &nbsp;            </div>
    </form>
    {else/}
    <form action="{:url('',array('action'=>'add'))}" name="images" method="post" class="form-horizontal">
        <label class="item-label">标题    </label>
        <div class="controls ">
            <input type="hidden" name="id" value="">
            <input type="text" name="title" value="" class="text input-large form-control" style="width: 400px"
                   placeholder="标题">
            <p class="lead"></p>
        </div>
        <label class="item-label">图片LOGO    </label>
        <div class="controls ">
            <div class="controls">
                <div id="upload_single_image_image" style="padding-bottom: 5px;" class="webuploader-container">
                    <div class="webuploader-pick">选择图片</div>
                    <div id="rt_rt_1b4t64277n7iv2s1e3vg7d1rtu1" style="position: absolute; top: 0px; left: 0px; width: 64px; height: 28px; overflow: hidden; bottom: auto; right: auto;">
                        <input type="file" name="file" class="webuploader-element-invisible" multiple="multiple"
                               accept="image/*">
                        <label style="opacity: 0; width: 100%; height: 100%; display: block; cursor: pointer; background: rgb(255, 255, 255);"></label>
                    </div>
                </div>
                <input class="attach" type="hidden" name="image" value="">
                <div class="upload-img-box">
                    <div class="upload-pre-item popup-gallery">

                    </div>
                </div>
            </div>
            <!--上传文件-->
            <script>
                $(function () {
                    var uploader_image= WebUploader.create({
                        // 选完文件后，是否自动上传。
                        auto: true,
                        // swf文件路径
                        swf: "__ROOT__js/ext/webuploader/js/Uploader.swf",
                        // 文件接收服务端。
                        server: "{:url('shop/upload')}",
                        // 选择文件的按钮。可选。
                        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                        pick: '#upload_single_image_image',
                        // 只允许选择图片文件
                        accept: {
                            title: 'Images',
                            extensions: 'gif,jpg,jpeg,bmp,png',
                            mimeTypes: 'image/*'
                        }
                    });
                    uploader_image.on('fileQueued', function (file) {
                        uploader_image.upload();
                    });
                    /*上传成功**/
                    uploader_image.on('uploadSuccess', function (file, data) {
                        //console.log(data);
                        if (data.status) {
                            $("[name='image']").val(data.id);
                            $("[name='image']").parent().find('.upload-pre-item').html(
                                '<div class="each"><a href="'+ data.url+'" disabled="true" title="点击查看大图"><img src="'+
                                data.url+'"></a><div class="text-center opacity del_btn" ></div>' +
                                '<div onclick="admin_image.removeImage($(this),'+data.id+')"  class="text-center del_btn">删除</div></div>');
                            uploader_image.reset();
                        } else {
                            updateAlert(data.info);
                            setTimeout(function () {
                                $('#top-alert').find('button').click();
                                $(that).removeClass('disabled').prop('disabled', false);
                            }, 1500);
                        }
                    });
                })
            </script>
        </div>
        <label class="item-label">内容简介    </label>
        <div class="controls ">
                    <textarea type="text" name="content" value="" class="text input-large form-control"
                              style="width: 400px"></textarea>
        </div>
        <label class="item-label">所属栏目    </label>
        <div class="controls ">
            <select name="cat_title" class="form-control" style="width:auto;">
                {foreach name="tag" item="c"}
                <option value="{$c.title}">{$c.title}&nbsp;</option>
                {/foreach}
            </select>
            <!--<select name="cat_id" class="form-control" style="width:auto;">-->
                <!--{foreach name="tag" item="c"}-->
                <!--<option value="{$c.id}">{$c.title}&nbsp</option>-->
                <!--{/foreach}-->
            <!--</select>-->
        </div>
        <label class="item-label">标题1(第一栏)    </label>
        <div class="controls ">
            <input type="text" name="title1" value="" class="text input-large form-control" style="width: 400px"></div>
        <label class="item-label">标题1介绍    </label>
        <div class="controls ">
            <script id="brief1" name="detile1" class="edui-default" style="width: 500px;"></script>
        </div>
        <label class="item-label">标题2(第二栏)    </label>
        <div class="controls ">
            <input type="text" name="title2" value="" class="text input-large form-control" style="width: 400px">
        </div>
        <label class="item-label">标题2介绍    </label>
        <div class="controls ">
            <script id="brief2" name="detile2" class="edui-default" style="width: 500px;"></script>
        </div>

        <label class="item-label">标题3(第三栏)    </label>
        <div class="controls ">
            <input type="text" name="title3" value="" class="text input-large form-control" style="width: 400px">
        </div>
        <label class="item-label">图文说明说明   </label>
        <div class="controls ">

            <script id="brief3" name="detile3" class="edui-default" style="width: 500px;"></script>

        </div>
        <label class="item-label">商品单价    </label>
        <div class="controls ">
            <input type="text" name="price" value="" class="text input-large form-control" style="width: 400px" placeholder="数字">
        </div>
        <label class="item-label">价格说明(第四栏)   </label>
        <div class="controls ">
            <input type="text" name="title4" value="" class="text input-large form-control" style="width: 400px">
        </div>
        <label class="item-label">优惠介绍    </label>
        <div class="controls ">
            <script id="brief4" name="detile4" class="edui-default" style="width: 500px;"></script>
        </div>
        <label class="item-label">价格选项   </label>
        <div class="controls ">

            <label style="display: block"><input type="text" name="price1[]" value="" style="width: 200px;margin-left: 10px;"
                                                 placeholder="价格说明" ><input type="text" name="price2[]" value=""
                                                                            style="width: 80px;margin-left: 10px;" placeholder="价格"></label>
            <label style="display: block"><input type="text" name="price1[]" value="" style="width: 200px;margin-left: 10px;"
                                                 placeholder="价格说明" ><input type="text" name="price2[]" value=""
                                                                            style="width: 80px;margin-left: 10px;" placeholder="价格"></label>
            <label style="display: block"><input type="text" name="price1[]" value="" style="width: 200px;margin-left: 10px;"
                                                 placeholder="价格说明" ><input type="text" name="price2[]" value=""
                                                                            style="width: 80px;margin-left: 10px;" placeholder="价格"></label>
            <label style="display: block"><input type="text" name="price1[]" value="" style="width: 200px;margin-left: 10px;"
                                                 placeholder="价格说明" ><input type="text" name="price2[]" value=""
                                                                            style="width: 80px;margin-left: 10px;" placeholder="价格"></label>

        </div>

        <label class="item-label">排序    </label>
        <div class="controls ">
            <input type="text" name="sort" value="" class="text input-large form-control" style="width: 400px"></div>
        <label class="item-label">状态    </label>
        <div class="controls ">
            <label for="id_stauts_0"><input id="id_stauts_0" name="status" value="0" type="radio" checked="">正常</label>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <label for="id_stauts_1"> <input id="id_stauts_1" name="status" value="1" type="radio">隐藏</label>
            &nbsp;&nbsp;&nbsp;&nbsp;</div>
        <label class="item-label">创建时间    </label>
        <div class="controls ">
            <input type="hidden" name="create_time" value="<?php echo time()?>">
            <input type="text" id="datetimepicker" data-field-name="create_time"
                   class="text input-large form-datetime time form-control" style="width: 400px"
                   value="<?php echo time_format(time())?>"
                   placeholder="请选择时间">
        </div>
        <div class="form-item">
            <button class="btn submit-btn ajax-post btn-success" id="submit" type="submit"
                    target-form="form-horizontal">确定</button>  &nbsp;<button onclick="javascript:history.back(-1);return false;" class="btn btn-return">返回</button>  &nbsp;            </div>
    </form>
    {/notempty}
</div>


</div>

</div>
{/block}

{block name="script"}
<script type="text/javascript">
//    if($('[data-type="checkbox"]').attr("checked") == true){
//        var value = $('#price1').val() + '￥' + $('#price2').val();
//        $('[data-type="checkbox"]').val(value) ;
//    }
    $(function(){
        $('[data-type="checkbox"]').click(function(){
            var txtalso = $('#price1').val() + '￥' + $('#price2').val();
            if($(this).prop("checked")) {

                $('[data-type="checkbox"]').val(txtalso);
            }else{
                $('[data-type="checkbox"]').val('') ;
            }
        });

    });
$(function(){
    $("input:button").click(function() {
        text = $("input:checkbox[name='message']:checked").map(function(index,elem) {
            return $(elem).val();
        }).get().join(',');
        alert("选中的checkbox的值为："+text);
    });
});

    //百度编辑器
    var  ue_brief;
    $(function () {
        var config = {toolbars:[['source','|','bold','italic','underline','fontsize','forecolor','justifyleft','fontfamily','|','map','emotion','insertimage','insertcode']],zIndex:977,initialFrameWidth:500,initialFrameHeight:400,autoHeightEnabled: false,'topOffset':$('#nav_bar').height()+$('#sub_nav').height()+5};
        ue_brief = UE.getEditor('brief1', config);
        ue_brief = UE.getEditor('brief2', config);
        ue_brief = UE.getEditor('brief3', config);
        ue_brief = UE.getEditor('brief4', config);
    });
    $('#datetimepicker').datetimepicker({
        language: "zh-CN",
        autoclose: true,
        format: 'yyyy-mm-dd hh:ii'
    });

    $(function () {
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query;
            } else {
                url += '?' + query;
            }
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
        //导航高亮

        //点击排序
        $('.list_sort').click(function () {
            var url = $(this).attr('url');
            var ids = $('.ids:checked');
            var param = '';
            if (ids.length > 0) {
                var str = new Array();
                ids.each(function () {
                    str.push($(this).val());
                });
                param = str.join(',');
            }

            if (url != undefined && url != '') {
                window.location.href = url + '/ids/' + param;
            }
        });
    });
</script>
{/block}